home *** CD-ROM | disk | FTP | other *** search
- VERSION 2.00
- Begin Form Btrv
- Caption = "Sample program using CallBtrv()"
- ClientHeight = 5160
- ClientLeft = 225
- ClientTop = 495
- ClientWidth = 7380
- Height = 5565
- Left = 165
- LinkMode = 1 'Source
- LinkTopic = "Form1"
- ScaleHeight = 5160
- ScaleWidth = 7380
- Top = 150
- Width = 7500
- Begin CommandButton Command18
- Caption = "Exit"
- Height = 375
- Left = 6000
- TabIndex = 33
- Top = 4560
- Width = 855
- End
- Begin CommandButton Command17
- Caption = "Get >"
- Height = 375
- Left = 4320
- TabIndex = 28
- Top = 4560
- Width = 855
- End
- Begin CommandButton Command16
- Caption = "Get <"
- Height = 375
- Left = 4320
- TabIndex = 27
- Top = 4080
- Width = 855
- End
- Begin TextBox INo
- Height = 285
- Left = 3240
- TabIndex = 40
- Top = 3960
- Width = 615
- End
- Begin TextBox FNo
- Height = 285
- Left = 1320
- TabIndex = 38
- Top = 3960
- Width = 855
- End
- Begin CommandButton Command4
- Caption = "End"
- Height = 375
- Left = 6000
- TabIndex = 3
- Top = 3600
- Width = 855
- End
- Begin CommandButton Command15
- Caption = "Get >="
- Height = 375
- Left = 4320
- TabIndex = 26
- Top = 3600
- Width = 855
- End
- Begin TextBox Text10
- Height = 285
- Left = 1320
- TabIndex = 36
- Top = 3600
- Width = 2775
- End
- Begin TextBox Keylength
- Height = 285
- Left = 1320
- TabIndex = 32
- Top = 3240
- Width = 1695
- End
- Begin CommandButton Command3
- Caption = "Close"
- Height = 375
- Left = 6000
- TabIndex = 2
- Top = 3120
- Width = 855
- End
- Begin CommandButton Command14
- Caption = "Get <="
- Height = 375
- Left = 4320
- TabIndex = 25
- Top = 3120
- Width = 855
- End
- Begin TextBox Key
- Height = 285
- Left = 1320
- TabIndex = 30
- Top = 2880
- Width = 2775
- End
- Begin CommandButton Command9
- Caption = "Delete"
- Height = 375
- Left = 6000
- TabIndex = 19
- Top = 2640
- Width = 855
- End
- Begin CommandButton Command13
- Caption = "Get ="
- Height = 375
- Left = 4320
- TabIndex = 24
- Top = 2640
- Width = 855
- End
- Begin TextBox Text9
- Height = 285
- Left = 360
- TabIndex = 17
- Top = 2280
- Width = 3735
- End
- Begin CommandButton Command8
- Caption = "Insert"
- Height = 375
- Left = 6000
- TabIndex = 18
- Top = 2160
- Width = 855
- End
- Begin CommandButton Command12
- Caption = "GetPrev"
- Height = 375
- Left = 4320
- TabIndex = 23
- Top = 2160
- Width = 855
- End
- Begin TextBox Text8
- Height = 285
- Left = 360
- TabIndex = 16
- Top = 2040
- Width = 3735
- End
- Begin TextBox Text7
- Height = 285
- Left = 360
- TabIndex = 15
- Top = 1800
- Width = 3735
- End
- Begin CommandButton Command7
- Caption = "Update"
- Height = 375
- Left = 6000
- TabIndex = 8
- Top = 1680
- Width = 855
- End
- Begin CommandButton Command6
- Caption = "GetNext"
- Height = 375
- Left = 4320
- TabIndex = 7
- Top = 1680
- Width = 855
- End
- Begin TextBox Text6
- Height = 285
- Left = 360
- TabIndex = 14
- Top = 1560
- Width = 3735
- End
- Begin TextBox Text5
- Height = 285
- Left = 360
- TabIndex = 13
- Top = 1320
- Width = 3735
- End
- Begin CommandButton Command19
- Caption = "Create"
- Height = 375
- Left = 6000
- TabIndex = 34
- Top = 1200
- Width = 855
- End
- Begin CommandButton Command11
- Caption = "Get Last"
- Height = 375
- Left = 4320
- TabIndex = 22
- Top = 1200
- Width = 855
- End
- Begin TextBox Text4
- Height = 285
- Left = 360
- TabIndex = 12
- Top = 1080
- Width = 3735
- End
- Begin TextBox Text3
- Height = 285
- Left = 360
- TabIndex = 11
- Top = 840
- Width = 3735
- End
- Begin CommandButton Command2
- Caption = "Open"
- Height = 375
- Left = 6000
- TabIndex = 1
- Top = 720
- Width = 855
- End
- Begin CommandButton Command5
- Caption = "Get First"
- Height = 375
- Left = 4320
- TabIndex = 6
- Top = 720
- Width = 855
- End
- Begin TextBox Text2
- Height = 285
- Left = 360
- TabIndex = 10
- Top = 600
- Width = 3735
- End
- Begin TextBox Text1
- Height = 285
- Left = 360
- TabIndex = 9
- Top = 360
- Width = 3735
- End
- Begin CommandButton Command1
- Caption = "Init"
- Height = 375
- Left = 6000
- TabIndex = 0
- Top = 240
- Width = 855
- End
- Begin CommandButton Command10
- Caption = "Use"
- Height = 375
- Left = 4320
- TabIndex = 20
- Top = 240
- Width = 855
- End
- Begin Label Label2
- Height = 255
- Left = 1320
- TabIndex = 5
- Top = 4440
- Width = 615
- End
- Begin Label Label1
- Caption = "RetCode"
- Height = 255
- Left = 360
- TabIndex = 4
- Top = 4440
- Width = 735
- End
- Begin Label Label8
- Caption = "Key #"
- Height = 255
- Left = 2400
- TabIndex = 39
- Top = 3960
- Width = 735
- End
- Begin Label Label7
- Caption = "File #"
- Height = 255
- Left = 360
- TabIndex = 37
- Top = 3960
- Width = 855
- End
- Begin Label Label6
- Caption = "Filename"
- Height = 255
- Left = 360
- TabIndex = 35
- Top = 3600
- Width = 855
- End
- Begin Label Label5
- Caption = "Keylen"
- Height = 255
- Left = 360
- TabIndex = 31
- Top = 3240
- Width = 615
- End
- Begin Label Label4
- Caption = "Keyval"
- Height = 255
- Left = 360
- TabIndex = 29
- Top = 2880
- Width = 615
- End
- Begin Label Label3
- Height = 375
- Left = 5280
- TabIndex = 21
- Top = 240
- Width = 615
- End
- Sub Command1_Click ()
- Dim Switches As String
- Rem set Btrieve switches
- Switches = "/m:48 /p:2048 /b:16 /f:20 /l:20 /n:12"
- Rem initialize Btrieve
- BStatus = WBtrvInit(Switches)
- Rem show Btrieve return code
- Label2.Caption = Str$(BStatus)
- End Sub
- Sub Command10_Click ()
- Rem this returns the number of records in the file
- CallBtrv B_USE, FileNo, 0
- Label2.Caption = Str$(BStatus)
- Label3.Caption = KeyVal
- End Sub
- Sub Command11_Click ()
- CallBtrv GET_LAST, FileNo, KeyNo
- ShowAcct
- End Sub
- Sub Command12_Click ()
- CallBtrv GET_PREV, FileNo, KeyNo
- ShowAcct
- End Sub
- Sub Command13_Click ()
- KeyVal = Key.Text
- CallBtrv GET_EQ, FileNo, KeyNo
- ShowAcct
- End Sub
- Sub Command14_Click ()
- KeyVal = Key.Text
- CallBtrv GET_LE, FileNo, KeyNo
- ShowAcct
- End Sub
- Sub Command15_Click ()
- KeyVal = Key.Text
- CallBtrv GET_GE, FileNo, KeyNo
- ShowAcct
- End Sub
- Sub Command16_Click ()
- KeyVal = Key.Text
- CallBtrv GET_LT, FileNo, KeyNo
- ShowAcct
- End Sub
- Sub Command17_Click ()
- KeyVal = Key.Text
- CallBtrv GET_GT, FileNo, KeyNo
- ShowAcct
- End Sub
- Sub Command18_Click ()
- Unload Btrv
- End
- End Sub
- Sub Command19_Click ()
- Rem disable this command so we don't delete the sample file
- Rem given with program
- Rem this sample code is given to show how to set up a buffer to enable
- Rem a program to create a file
- Exit Sub
- Rem dimension Specs for key characteristics for 6 segments
- Dim Specs As KEY_6SEG
- Rem the file number
- FileNo = Val(FNo.Text)
- Rem set KeyNo to 0 to create a file over an existing file
- Rem set KeyNo to -1 if you do not want Btrieve to create a new file
- Rem over an existing file - Btrieve will return an error code.
- KeyNo = Val(INo.Text)
- Rem assign file characteristics
- Specs.RecLen = GlAcctLen ' length of record
- Specs.PgSize = 1024 ' page size
- Specs.NoOfIndex = 3 ' number of keys
- Specs.NotUsed = 0&
- Specs.FileFlags = H0% ' file specifications
- Specs.ResWrd = 0
- Specs.Alloc = 0 ' space to preallocate
- Rem key specifications
- Specs.KeyPos1 = 1 ' position of first segment
- Specs.KeyLen1 = 20 ' length of first segment
- Specs.KeyFlags1 = KF_STRING + KF_MODIFIABLE ' key characteristics
- Specs.NotUsed1 = 0&
- Specs.Ext_Nul1 = 0
- Specs.ResWrd1 = 0&
- Specs.KeyPos2 = 1 ' position of second segment ...
- Specs.KeyLen2 = 8
- Specs.KeyFlags2 = KF_STRING + KF_MODIFIABLE + KF_SEGMENT
- Specs.NotUsed2 = 0&
- Specs.Ext_Nul2 = 0
- Specs.ResWrd2 = 0&
- Specs.KeyPos3 = 13
- Specs.KeyLen3 = 8
- Specs.KeyFlags3 = KF_STRING + KF_MODIFIABLE + KF_SEGMENT
- Specs.NotUsed3 = 0&
- Specs.Ext_Nul3 = 0
- Specs.ResWrd3 = 0&
- Specs.KeyPos4 = 9
- Specs.KeyLen4 = 3
- Specs.KeyFlags4 = KF_STRING + KF_MODIFIABLE
- Specs.NotUsed4 = 0&
- Specs.Ext_Nul4 = 0
- Specs.ResWrd4 = 0&
- Specs.KeyPos5 = 1
- Specs.KeyLen5 = 8
- Specs.KeyFlags5 = KF_STRING + KF_DUPLICATE + KF_MODIFIABLE + KF_SEGMENT
- Specs.NotUsed5 = 0&
- Specs.Ext_Nul5 = 0
- Specs.ResWrd5 = 0&
- Specs.KeyPos6 = 65
- Specs.KeyLen6 = 12
- Specs.KeyFlags6 = KF_STRING + KF_DUPLICATE + KF_MODIFIABLE
- Specs.NotUsed6 = 0&
- Specs.Ext_Nul6 = 0
- Specs.ResWrd6 = 0&
- LSet BtrvBuf = Specs ' assign file characteristics to Btrieve buffer
- CallBtrv B_CREATE, FileNo, KeyNo ' create the file
- Label2.Caption = Str$(BStatus)
- End Sub
- Sub Command2_Click ()
- Rem open a Btrieve file
- Rem the key number contains how the file is opened
- Rem OM_NORNAL = read/write using pre-imaging
- Rem OM_ACCELERATED = accelerated access
- Rem OM_READONLY = read only
- Rem OM_VERIFY = verifies data is correct on all writes
- Rem OM_EXCLUSIVE = exclusive mode
- CallBtrv B_OPEN, FileNo, OM_NORMAL
- Label2.Caption = Str$(BStatus)
- End Sub
- Sub Command3_Click ()
- CallBtrv B_CLOSE, FileNo, KeyNo
- Label2.Caption = Str$(BStatus)
- End Sub
- Sub Command4_Click ()
- Rem stop Btrieve
- Rem usually you would put this in a Form_Unload event
- Rem be sure to close all files first
- BStatus = WBtrvStop()
- Label2.Caption = Str$(BStatus)
- End Sub
- Sub Command5_Click ()
- CallBtrv GET_FIRST, FileNo, KeyNo
- ShowAcct
- End Sub
- Sub Command6_Click ()
- CallBtrv GET_NEXT, FileNo, KeyNo
- Label2.Caption = Str$(BStatus)
- ShowAcct
- End Sub
- Sub Command7_Click ()
- ChartRec.GlId = Text1.Text
- ChartRec.GlAcct = Text2.Text
- ChartRec.GlName = Text3.Text
- ChartRec.GlType = Text4.Text
- ChartRec.GlParen = Val(Text5.Text)
- ChartRec.GlMaster = Val(Text6.Text)
- ChartRec.GlBalance = Val(Text7.Text)
- ChartRec.GlSort = Text8.Text
- ChartRec.GlNoOfHist = Val(Text9.Text)
- CallBtrv B_UPDATE, FileNo, KeyNo
- UpdateVars
- End Sub
- Sub Command8_Click ()
- ChartRec.GlId = Text1.Text
- ChartRec.GlAcct = Text2.Text
- ChartRec.GlName = Text3.Text
- ChartRec.GlType = Text4.Text
- ChartRec.GlParen = Val(Text5.Text)
- ChartRec.GlMaster = Val(Text6.Text)
- ChartRec.GlBalance = Val(Text7.Text)
- ChartRec.GlSort = Text8.Text
- ChartRec.GlNoOfHist = Val(Text9.Text)
- CallBtrv B_INSERT, FileNo, KeyNo
- UpdateVars
- End Sub
- Sub Command9_Click ()
- CallBtrv B_DELETE, FileNo, 0
- UpdateVars
- End Sub
- Sub FNo_LostFocus ()
- FileNo = Val(FNo.Text)
- End Sub
- Sub Form_Load ()
- ' change the path to your directory
- Path = "m:\vb\btrv\"
- FileName(0) = "GLACCT.BTR"
- Rem integer containing the length of each key
- Rem in the form KeyLen(FileNo,KeyNo)
- KeyLen(0, 0) = 20
- KeyLen(0, 1) = 19
- KeyLen(0, 2) = 20
- INo.Text = "0" ' default key number
- FNo.Text = "0" ' default file number
- FileNo = 0
- KeyNo = 0
- Text10.Text = Path + FileName(FileNo)
- End Sub
- Sub INo_LostFocus ()
- KeyNo = Val(INo.Text)
- End Sub
- Sub ShowAcct ()
- Text1.Text = ChartRec.GlId
- Text2.Text = ChartRec.GlAcct
- Text3.Text = ChartRec.GlName
- Text4.Text = ChartRec.GlType
- Text5.Text = Str$(ChartRec.GlParen)
- Text6.Text = Str$(ChartRec.GlMaster)
- Text7.Text = Format$(ChartRec.GlBalance, "##,###,##0.00")
- Text8.Text = ChartRec.GlSort
- Text9.Text = Str$(ChartRec.GlNoOfHist)
- UpdateVars
- End Sub
- Sub UpdateVars ()
- Label2.Caption = Str$(BStatus)
- Key.Text = KeyVal
- KeyLength.Text = Str$(Len(KeyVal))
- End Sub
-